<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CSI.Directory.Core.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	New Listing
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="full-content">
    <h2>Manage listing</h2>

    <form name="listingform" method="post" action="/Directory/EditListing" onsubmit="return validate()" enctype="multipart/form-data">
        <table cellspacing="0" cellpadding="15" border="0" class="datatable">
            <tbody>
                <tr>
                    <td colspan="2" class="tabletitle">
                        General Information
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Company:
                    </td>
                    <td class="dataentry">
                        <input type="text" size="60" value="<%=((Listing)ViewData["Listing"]).Name %>" name="title" /><span style="color:red">*</span>
                        
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Contact Name:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="100" value="<%=((Listing)ViewData["Listing"]).Contact %>" name="contact" /><span style="color:red">*</span>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        E-mail:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).Email %>" name="email" />
                    </td>
                </tr>
                <tr>
                    <td>
                        URL:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="255" value="<%=((Listing)ViewData["Listing"]).Url %>" name="url" style="width: 425px;" /><span style="color:red">*</span>
                    </td>
                </tr>
                 <tr>
                    <td>
                        Phone:
                    </td>
                    <td class="dataentry">
                        <input type="text" value="<%=((Listing)ViewData["Listing"]).Phone %>" name="phone" />
                    </td>
                </tr>            
            
                <tr>
                    <td class="tabletitle" colspan="2">
                        Location
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Address Line1:
                        <br />
                        <br />
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).AddressLine1 %>" name="address" /><span style="color:red">*</span>
                        <span>Street Address, P.O. box </span>
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Address Line2:
                        <br />
                        <br />
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).AddressLine2 %>" name="address2" />
                        <span>Apartment, suite, unit, building, floor, etc. </span>
                    </td>
                </tr>
                 
                <tr>
                    <td>
                        City:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).City %>" name="city" /><span style="color:red">*</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        State:
                    </td>
                    <td class="dataentry">
                        <select name="state" id="state">
	                        <option value="AL">AL</option>
	                        <option value="AK">AK</option>
	                        <option value="AZ">AZ</option>
	                        <option value="AR">AR</option>
	                        <option value="CA">CA</option>
	                        <option value="CO">CO</option>
	                        <option value="CT">CT</option>
	                        <option value="DE">DE</option>
	                        <option value="DC">DC</option>
	                        <option value="FL">FL</option>
	                        <option value="GA">GA</option>
	                        <option value="HI">HI</option>
	                        <option value="ID">ID</option>
	                        <option value="IL">IL</option>
	                        <option value="IN">IN</option>
	                        <option value="IA">IA</option>
	                        <option value="KS">KS</option>
	                        <option value="KY">KY</option>
	                        <option value="LA">LA</option>
	                        <option value="ME">ME</option>
	                        <option value="MD">MD</option>
	                        <option value="MA">MA</option>
	                        <option value="MI">MI</option>
	                        <option value="MN">MN</option>
	                        <option value="MS">MS</option>
	                        <option value="MO">MO</option>
	                        <option value="MT">MT</option>
	                        <option value="NE">NE</option>
	                        <option value="NV">NV</option>
	                        <option value="NH">NH</option>
	                        <option value="NJ">NJ</option>
	                        <option value="NM">NM</option>
	                        <option value="NY">NY</option>
	                        <option value="NC">NC</option>
	                        <option value="ND">ND</option>
	                        <option value="OH">OH</option>
	                        <option value="OK">OK</option>
	                        <option value="OR">OR</option>
	                        <option value="PA">PA</option>
	                        <option value="RI">RI</option>
	                        <option value="SC">SC</option>
	                        <option value="SD">SD</option>
	                        <option value="TN">TN</option>
	                        <option value="TX">TX</option>
	                        <option value="UT">UT</option>
	                        <option value="VT">VT</option>
	                        <option value="VA">VA</option>
	                        <option value="WA">WA</option>
	                        <option value="WV">WV</option>
	                        <option value="WI">WI</option>
	                        <option value="WY">WY</option>
                        </select><span style="color:red">*</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        Zipcode:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="10" value="<%=((Listing)ViewData["Listing"]).Zip %>" name="zipcode" /><span style="color:red">*</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="tabletitle">
                        Image <span>(200px X 200px) (JPG or GIF)</span>
                    </td>
                </tr>
                <tr>
                    <td class="alignTop">
                        Image Source:
                    </td>
                    <td class="dataentry">
                        <input name="image" size="50" type="file">
                        <br /><span>Image width and height must be less than 200 pixels. Max file size 1.5 MB. Transparent .gif
                            not supported</span>
                            <br /><%=((Listing)ViewData["Listing"]).Image %>
                            
                        
                    </td>
                </tr>
    			
                <tr>
                    <td colspan="2" class="tabletitle">
                        Summary Description
                    </td>
                </tr>
                <tr>
                    <td>
                        Description:
                    </td>
                    <td class="dataentry">
                        <textarea name="description" rows="10" cols="60">
                        <%=((Listing)ViewData["Listing"]).Description %></textarea>
                        
                    </td>
                </tr>
               <tr>
		        <td colspan="2" class="tabletitle">
			        Tags for the search <span>comma seperated</span>
		        </td>
	        </tr>
	        <tr>
               <td>
                   Tags:
               </td>
                <td class="dataentry">
                    <input name="keywords" value="<%=((Listing)ViewData["Listing"]).Keywords %>" size="40" /><span>ex. Auto Parts,Tires,Engine Repair</span>
                </td>
            </tr>
          
          </tbody>
        </table>
    <div id="error" style="color:red"></div>
    <input type="submit" value="Submit" />
    <input type="hidden" value="<%=((Listing)ViewData["Listing"]).Id %>" name="id" />
    </form>
    <br /><br />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("input").focus(function() { $(this).css('border-color', '#eecc00'); });
            $("textarea").focus(function() { $(this).css('border-color', '#eecc00'); });
            $("input").blur(function() { $(this).css('border-color', '#999'); });
            $("textarea").blur(function() { $(this).css('border-color', '#999'); });
            $("#state").val('<%=((Listing)ViewData["Listing"]).State %>');

        });
     
      
      function validate()
      {
        $("#error").html("<ul></ul>");
        
//        if(f.email.value.length < 7 || f.email.value.length == "")
//        {
//            $("#error").append("Email must contain 7 or more characters.");
//            return false;
//        }
        
        if(document.listingform.title.value.length < 2 || document.listingform.title.value == " ")
        {
            $("#error ul").append("<li>Name must contain 2 or more characters.</li>");
            return false;
        }
        if(document.listingform.url.value.length < 8 || document.listingform.url.value == " ")
        {
            $("#error ul").append("<li>Url must contain 8 or more characters.</li>");
            return false;
        }
        if(document.listingform.address.value.length < 5 || document.listingform.address.value == " ")
        {
            $("#error ul").append("<li>Address must contain 5 or more characters.</li>");
            return false;
        }
        if(document.listingform.city.value.length < 3 || document.listingform.city.value == "")
        {
            $("#error ul").append("<li>City must contain 3 or more characters.</li>");
            return false;
        }
        if(document.listingform.state.value.length < 2 || document.listingform.state.value == "")
        {
            $("#error ul").append("<li>State must contain 2 or more characters.</li>");
            return false;
        }
        if(document.listingform.zipcode.value.length < 5 || document.listingform.zipcode.value == "")
        {
            $("#error ul").append("<li>Zipcode must contain 5 or more characters.</li>");
            return false;
        }
        
        
        return true;
        
      }
      
    </script>

</div>
</asp:Content>


